package com.billow.events
{
	import com.billow.net.UDPSocket;
	
	import flash.events.Event;
	import flash.utils.ByteArray;
	
	public class UDPSocketEvent extends Event
	{
		/** 接收数据 */
		public static const RECEIVE:String = "receive";
		/** IO错误 */
		public static const IO_ERROR:String = "ioError";
		/** 数据包长度错误 */
		public static const RANGE_ERROR:String = "rangeError";
		/** 服务器打开失败 */
		public static const FAILED:String = "failed";
		/** 服务器打开成功 */
		public static const SUCCEED:String = "succeed";
		
		private var _udpSocket:UDPSocket;
		
		public function UDPSocketEvent(type:String ,udpSocket:UDPSocket=null ,bubbles:Boolean=false, cancelable:Boolean=false)
		{
			super(type, bubbles, cancelable);
			_udpSocket = udpSocket;
		}
		
		
		/** 远程设备的 IP 地址 */
		public function get remoteAddress():String {return _udpSocket.remoteAddress;}
		/** 远程设备的端口 */
		public function get remotePort():int {return _udpSocket.remotePort;}
		/** 参数 */
		public function get data():ByteArray {return _udpSocket.data;}
		/** 命令 */
		public function get cmd():String {return _udpSocket.cmd;}
	}
}